![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
q3-core-responder
Advanced tools
Q3 responder handles two responsibilities: (1) assigning HTTP status codes to unhandled exceptions and (2) throwing custom errors in the stack. Within client projects, the first is irrelevant as Q3 registers the functionality via global express middle
Readme
Q3 responder handles two responsibilities: (1) assigning HTTP status codes to unhandled exceptions and (2) throwing custom errors in the stack. Within client projects, the first is irrelevant as Q3 registers the functionality via global express middleware. However, the second is very common when dealing with custom validation logic.
exception
The exception
export offers a chainable API for building
general and field-level errors. When constructing, the first
parameter will correspond to an HTTP status code (see table
below).
Error | Code |
---|---|
BadRequest | 400 |
Authentication | 401 |
Authorization | 403 |
ResourceNotFound | 404 |
Conflict | 409 |
Gone | 410 |
Preprocessing | 412 |
Validation | 422 |
InternalServer | 500 |
Afterwards, you can chain the following methods. You can
invoke msg
and field
in any order but boomerang
, log
and throw
should end your chain.
Method | Param | Description |
---|---|---|
msg | String | The language key for a message to decorate the HTTP response |
field | String or Object | The field-level error to report. If a string, it will duplicate the msg output. If an object, you can provide custom messages and map to multiple fields. |
throw | A custom error will throw in your stack | |
boomerang | A custom error will return | |
log | A custom error will log to console |
const { exception } = require('q3-core-responder');
function doSomething(args = {}) {
if (args.bad)
exception('Conflict')
.msg('custom18nMessageKey')
.field('name')
.throw();
if (args.reallyBad)
exception('Validation')
.msg('custom18nMessageKey')
.field({
in: 'application', // can be anything
name: ['field1', 'field2'],
msg: 'dataNoGood',
})
.throw();
}
FAQs
Q3 responder handles two responsibilities: (1) assigning HTTP status codes to unhandled exceptions and (2) throwing custom errors in the stack. Within client projects, the first is irrelevant as Q3 registers the functionality via global express middle
The npm package q3-core-responder receives a total of 108 weekly downloads. As such, q3-core-responder popularity was classified as not popular.
We found that q3-core-responder demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.